<template>
  <div>
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
      <el-row>
        <el-col :span="24">
          <el-form-item label="数据分类" prop="dataType">
            <el-input v-model="ruleForm.dataType" clearable />
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
        <el-button @click="resetForm('ruleForm')">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        ruleForm: {
          dataType: "",
        },
        rules: {
          dataType: [{
            required: true,
            message: "请填写数据名称",
            trigger: "blur",
          }, ]
        }
      };
    },
    methods: {
      // 表单提交
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$server
              .dataClassifySubmit({
                ...this.ruleForm,
              })
              .then((res) => {
                console.log(res)
                this.$message({
                  type: "success",
                  message: "添加成功!",
                });
              });
            this.$emit('close')
            this.$emit('dataClassify')
          } else {
            // console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$emit('close')
      }
    }
  }
</script>

<style>
</style>
